﻿using System.Collections.Generic;
using Transformable_Engine_v2.Engine.GameObjects.Containers;
using Transformable_Engine_v2.Engine.Transformable_Math.Geometry;

namespace AngryManagementMayhem.Controller.Map
{
    public abstract class BaseMap : Container
    {
        public static readonly TE_Vector2 MapSize = new TE_Vector2(22, 15) * CollisionDefinition.CollisionSize;
        public Dictionary<int, BaseScreen> Screens { get; private set; }

        public Container ProjectileScreen { get; protected set; }
        public Container BackParticleScreen { get; protected set; }
        public Container FrontParticleScreen { get; protected set; }

        protected BaseMap()
        {
            Screens = new Dictionary<int, BaseScreen>();

            ProjectileScreen = new Container();
            BackParticleScreen = new Container();
            FrontParticleScreen = new Container();
        }

        protected void AddScreen(int positionX, int positionY, BaseScreen screen)
        {
            Screens.Add(MapLocationToIndex(positionX, positionY), screen);

            screen.Position = new TE_Vector2(MapSize.X * positionX, MapSize.Y * positionY);
            AddChildren(screen);
        }

        public static int MapLocationToIndex(int indexX, int indexY)
        {
            return indexX + indexY * 1000;
        }
    }
}